Skip to content

Conversation

HemantKArya
Copy link

Enable access to Linux kernel types on Android targets while excluding a small set of Linux userspace features that are not available on Android (XDP, io_uring, certain STATX constants), restoring Android builds without changing Linux behavior.


Motivation / Background

Recently the crate started failing to build for Android targets with errors like:

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `linux_raw_sys`
error[E0659]: `STATX_ATTR_NODUMP` is ambiguous

Root cause: Android had been explicitly excluded from the linux_raw_dep / linux-raw-sys path in build.rs / Cargo.toml, which prevented Android builds from getting Linux kernel constant / syscall/type definitions that are required even when using the libc backend. Bionic (Android libc) does not expose all kernel-level constants and some syscalls/constants are only available via linux-raw-sys. At the same time, Android’s userspace is missing a few advanced Linux-only features and constants (e.g. SOL_XDP, RWF_*) — those should remain disabled on Android rather than enabled.

This PR restores Android builds by enabling access to linux-raw-sys on Android targets, and then selectively disables features that truly require Linux userspace support not present in Bionic.


What this PR changes

High level

  • Enable linux-raw-sys kernel types for Android targets so Android can access kernel constants/types it needs.
  • Keep Linux functionality unchanged.
  • Add targeted #[cfg(...)] guards so features not supported by Bionic (XDP, io_uring, certain STATX usages) remain disabled on Android.
  • Update a small test to exclude Android-only-incompatible assertions.

Rationale / Technical explanation

  • Android uses the Linux kernel, so kernel-level types and syscall constants are valid on Android and MUST be available to the crate (via linux-raw-sys) so code paths that depend on kernel definitions compile.

  • However, Android’s userspace (Bionic) does not expose certain Linux userspace constants and features:

    • XDP / AF_XDP / SOL_XDP: SOL_XDP and related constants are not present in Bionic. XDP is a Linux networking acceleration feature that is not applicable to Android userspace; those code paths are guarded so they are only enabled for desktop/server Linux.
    • io_uring: RWF_* (e.g., RWF_NOWAIT, RWF_DSYNC) flags and other io_uring-related userspace support may be absent in Bionic. io_uring code is therefore excluded on Android targets.
    • STATX constants: Some STATX constants can be defined both in libc and linux-raw-sys, causing ambiguity; adding Android to the exclusion list resolves the ambiguity and keeps the definitions consistent.

Net effect: Android gets what it needs from kernel types; Linux retains full feature set. No behavior changes for Linux targets.


Testing performed

All CI workflow targets tested locally/in-workflow:

Android (all passing)

  • aarch64-linux-android (default & use-libc features)
  • armv7-linux-androideabi (use-libc)
  • x86_64-linux-android (use-libc)
  • i686-linux-android (use-libc)

Linux (all passing)

  • Default build
  • all-apis feature builds
  • use-libc,all-apis builds
  • linux_latest,all-apis builds
  • All library tests pass (51/51)

(These are the results from my test runs; CI logs are attached in the workflow that exercised all Android and Linux variants.)


  • Changes are intentionally minimal and scoped:

    • Only enables kernel-type dependency for Android.
    • Only disables a small, well-defined subset of features on Android that are known not to be available in Bionic (XDP, io_uring, RWF flags, certain STATX exposures).
  • Linux behavior is unchanged — #[cfg(all(linux_raw_dep, target_os = "linux"))] keeps full Linux feature set intact.

  • Tests and CI flows covering both Android and Linux have been exercised and pass.


References (for reviewer verification)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant